package com.mxsoft.proxy;

import java.lang.reflect.Proxy;

public class DynamicProxyTest {
    public static void main(String[] args) {
        IHello hello = new HelloImpl();

        IHello o = (IHello) Proxy.newProxyInstance(DynamicProxyTest.class.getClassLoader(), new Class[]{IHello.class}, new HelloInvocationHandler(hello));
//        System.out.println(o.sayHello("alex"));
//        System.out.println(o.toString());
        //继承自Object类的方法中，toString、hashCode、equals，会被代理，其他的不会被代理
        System.out.println(o.getClass());
        System.out.println(o.getClass().getGenericSuperclass());
    }
}
